import numpy as np

def Init3DCurveC(U:[float,float,float,...], Pts:[list,list,list,...]):
    '''
        功能：求插值三维曲线数据点的幂基参数多项式系数
        输入：Pts-依次是数据点list。
              U-数据点参数化list
        输出：Cs-依次是幂基参数多项式系数矢量list。
    '''
    n = len(Pts)
    Pts = np.transpose(Pts, [1,0]).reshape(3,n,1)
    # 变量矩阵
    AA = np.ones((n,n))
    for i in range(n):
        for j in range(1,n):
            AA[i,j] = U[i]**j
    Cs = np.linalg.inv(AA).reshape(1,n,n) @ Pts
    return Cs.reshape(3,n).T

if __name__ == '__main__':
    U = [0,0.2,0.4,1]
    Pts = [(0,2,3),(3,4,5),
           (4,5,6),(5,7,8)]
    c = Init3DCurveC(U, Pts)
    print(c)